package sumpayTest4;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.junit.Test;


public class Test4 {
	Connection conn=null;
	public Test4() throws Exception {
	 conn=GetConnection.getconnection();
	}
	public void f1() throws SQLException{
		String sql = "insert into TB_test_user values(?,?)";
		PreparedStatement ps = conn.prepareStatement(sql);
		ps.setInt(1, 123456);
		ps.setString(2, "dfdsf");
		ps.executeUpdate();
		conn.commit();
	}
	public void f2() throws SQLException {
		String sql ="select * from TB_test_user";
		PreparedStatement ps=conn.prepareStatement(sql);
		ResultSet rs=ps.executeQuery();
		while(rs.next()){
			System.out.println(rs.getInt(1)+"-"+rs.getString(2));
		}
	}
	public static void main(String[] args) throws SQLException, Exception {
		new Test4().f2();
	}
	
}
